package com.gz.steak.utils.security;

import com.gz.steak.modules.system.pojo.model.LoginModel;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @Author 刘牌
 * @Date 2020/3/19 0019 11:12
 * @Version 1.0
 */

public class SpringSecurityUtil {

    /**
     * 加密
     * @return
     */
    public static String encode(String username , String password){
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(username+password);
    }

    /**
     * 核实密码
     * @param cryptPassword
     * @return
     */
    public static boolean check(LoginModel model , String cryptPassword){
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(model.getUserName() + model.getUserPassword(),cryptPassword);
    }
}
